/*
 * main.cpp
 *
 *  Created on: 30/04/2011
 *      Author: dela
 */

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "common/Mutex.h"
#include "common/Connection.h"
#include "Server.h"

using namespace std;

Connection *Connection::conn = NULL;
Server *Server::server = NULL;

/**
 *
 */
int main(int argc, char *argv[]) {
	// Si la cantidad de parametros no es la correcta:
	if (argc != 3) {
		fprintf(stderr, "Parametros esperados: instructorPort, studentPort\n");
		return 1;
	}
	int portInstructor = atoi(argv[1]);
	int portStudent = atoi(argv[2]);

	// Inicio el server:
	Server::createSingleton(portInstructor, portStudent);
	Server *server = Server::getInstance();
	server->acceptConnections();

	char c = 0;
	while (c != 'q') {
		std::cin >> c;
	}
	cout << "Desconectar y Salir recibido" << endl;
	server->serverShutdown();
	return 0;
}
